home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / xampp-win32-1.6.5-installer.exe / phpMyAdmin / main.php < prev    next >
Encoding:
PHP Script  |  2007-12-20  |  15.2 KB  |  447 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: main.php 10635 2007-09-13 20:48:07Z lem9 $
  6.  */
  7.  
  8. /**
  9.  * Don't display the page heading
  10.  */
  11. if (!defined('PMA_DISPLAY_HEADING')) {
  12.     define('PMA_DISPLAY_HEADING', 0);
  13. }
  14.  
  15. /**
  16.  * Gets some core libraries and displays a top message if required
  17.  */
  18. require_once './libraries/common.inc.php';
  19.  
  20. // Handles some variables that may have been sent by the calling script
  21. $GLOBALS['db'] = '';
  22. $GLOBALS['table'] = '';
  23. $show_query = '1';
  24. require_once './libraries/header.inc.php';
  25.  
  26. // Any message to display?
  27. if (! empty($message)) {
  28.     PMA_showMessage($message);
  29.     unset($message);
  30. }
  31.  
  32. $common_url_query =  PMA_generate_common_url('', '');
  33.  
  34. // this div is required for containing divs can be 50%
  35. echo '<div id="maincontainer">' . "\n";
  36.  
  37. /**
  38.  * Displays the mysql server related links
  39.  */
  40. if ($server > 0) {
  41.  
  42.     require_once './libraries/check_user_privileges.lib.php';
  43.     // why this? a non-priv user should be able to change his
  44.     // password if the configuration permits
  45.     //$cfg['ShowChgPassword'] = $is_superuser = PMA_isSuperuser();
  46.     $is_superuser = PMA_isSuperuser();
  47.  
  48.     if ($cfg['Server']['auth_type'] == 'config') {
  49.         $cfg['ShowChgPassword'] = false;
  50.     }
  51. }
  52. ?>
  53.  
  54.     <div id="mysqlmaininformation">
  55. <?php
  56. if ($server > 0) {
  57.     // robbat2: Use the verbose name of the server instead of the hostname
  58.     //          if a value is set
  59.     $server_info = '';
  60.     if (!empty($cfg['Server']['verbose'])) {
  61.         $server_info .= htmlspecialchars($cfg['Server']['verbose']);
  62.         if ($GLOBALS['cfg']['ShowServerInfo']) {
  63.             $server_info .= ' (';
  64.         }
  65.     }
  66.     if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
  67.         $server_info .= PMA_DBI_get_host_info();
  68.     }
  69.  
  70.     if (!empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
  71.         $server_info .= ')';
  72.     }
  73.     // loic1: skip this because it's not a so good idea to display sockets
  74.     //        used to everybody
  75.     // if (!empty($cfg['Server']['socket']) && PMA_PHP_INT_VERSION >= 30010) {
  76.     //     $server_info .= ':' . $cfg['Server']['socket'];
  77.     // }
  78.     $mysql_cur_user_and_host = PMA_DBI_fetch_value('SELECT USER();');
  79.  
  80.  
  81.     // should we add the port info here?
  82.     $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
  83.                         ? $GLOBALS['cfg']['Server']['verbose']
  84.                         : $GLOBALS['cfg']['Server']['host']);
  85.     echo '<h1 xml:lang="en" dir="ltr">' . $short_server_info .'</h1>' . "\n";
  86.     unset($short_server_info);
  87. } else {
  88.     // Case when no server selected
  89.     //echo '<h1 xml:lang="en" dir="ltr">MySQL</h1>' . "\n";
  90. }
  91.  
  92. if ($server > 0) {
  93.     echo '<ul>' . "\n";
  94.  
  95.     if ($GLOBALS['cfg']['ShowServerInfo']) {
  96.         PMA_printListItem($strServerVersion . ': ' . PMA_MYSQL_STR_VERSION, 'li_server_info');
  97.         PMA_printListItem($strProtocolVersion . ': ' . PMA_DBI_get_proto_info(),
  98.             'li_mysql_proto');
  99.         PMA_printListItem($strServer . ': ' . $server_info, 'li_server_info');
  100.         PMA_printListItem($strUser . ': ' . htmlspecialchars($mysql_cur_user_and_host),
  101.             'li_user_info');
  102.     } else {
  103.         PMA_printListItem($strServerVersion . ': ' . PMA_MYSQL_STR_VERSION, 'li_server_info');
  104.         PMA_printListItem($strServer . ': ' . $server_info, 'li_server_info');
  105.     }
  106.  
  107.     if ($cfg['AllowAnywhereRecoding'] && $allow_recoding && PMA_MYSQL_INT_VERSION < 40100) {
  108.         echo '<li id="li_select_mysql_charset">';
  109.         ?>
  110.             <form method="post" action="index.php" target="_parent">
  111.             <input type="hidden" name="server" value="<?php echo $server; ?>" />
  112.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  113.             <?php echo $strMySQLCharset;?>:
  114.             <select name="convcharset"  xml:lang="en" dir="ltr"
  115.                 onchange="this.form.submit();">
  116.         <?php
  117.         foreach ($cfg['AvailableCharsets'] as $tmpcharset) {
  118.             if ($convcharset == $tmpcharset) {
  119.                 $selected = ' selected="selected"';
  120.             } else {
  121.                 $selected = '';
  122.             }
  123.             echo '            '
  124.                . '<option value="' . $tmpcharset . '"' . $selected . '>' . $tmpcharset . '</option>' . "\n";
  125.         }
  126.         ?>
  127.             </select>
  128.             <noscript><input type="submit" value="<?php echo $strGo;?>" /></noscript>
  129.             </form>
  130.         </li>
  131.         <?php
  132.     } elseif (PMA_MYSQL_INT_VERSION >= 40100) {
  133.         echo '    <li id="li_select_mysql_charset">';
  134.         echo '        ' . $strMySQLCharset . ': '
  135.            . '        <strong xml:lang="en" dir="ltr">'
  136.            . '           ' . $mysql_charsets_descriptions[$mysql_charset_map[strtolower($charset)]] . "\n"
  137.            . '           (' . $mysql_charset_map[strtolower($charset)] . ')' . "\n"
  138.            . '        </strong>' . "\n"
  139.            . '    </li>' . "\n"
  140.            . '    <li id="li_select_mysql_collation">';
  141.         echo '        <form method="post" action="index.php" target="_parent">' . "\n"
  142.            . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
  143.            . '            <label for="select_collation_connection">' . "\n"
  144.            . '                ' . $strMySQLConnectionCollation . ': ' . "\n"
  145.            . '            </label>' . "\n"
  146.            . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, 4, true)
  147.            . '            <noscript><input type="submit" value="' . $strGo . '" /></noscript>' . "\n"
  148.            // put the doc link in the form so that it appears on the same line
  149.            . PMA_showMySQLDocu('MySQL_Database_Administration', 'Charset-connection') . "\n"
  150.            . '        </form>' . "\n"
  151.            . '    </li>' . "\n";
  152.     }
  153.  
  154.     if ($cfg['ShowCreateDb']) {
  155.         echo '<li id="li_create_database">';
  156.         require './libraries/display_create_database.lib.php';
  157.         echo '</li>' . "\n";
  158.     }
  159.  
  160.     PMA_printListItem($strMySQLShowStatus, 'li_mysql_status',
  161.         './server_status.php?' . $common_url_query);
  162.     PMA_printListItem($strMySQLShowVars, 'li_mysql_variables',
  163.         './server_variables.php?' . $common_url_query, 'show-variables');
  164.     PMA_printListItem($strProcesses, 'li_mysql_processes',
  165.         './server_processlist.php?' . $common_url_query, 'show-processlist');
  166.  
  167.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  168.         PMA_printListItem($strCharsetsAndCollations, 'li_mysql_collations',
  169.             './server_collations.php?' . $common_url_query);
  170.     }
  171.  
  172.     PMA_printListItem($strStorageEngines, 'li_mysql_engines',
  173.         './server_engines.php?' . $common_url_query);
  174.  
  175.     if ($is_reload_priv) {
  176.         PMA_printListItem($strReloadPrivileges, 'li_flush_privileges',
  177.             './server_privileges.php?flush_privileges=1&' . $common_url_query, 'flush');
  178.     }
  179.  
  180.     if ($is_superuser) {
  181.         PMA_printListItem($strPrivileges, 'li_mysql_privilegs',
  182.             './server_privileges.php?' . $common_url_query);
  183.     }
  184.  
  185.     $binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', null, PMA_DBI_QUERY_STORE);
  186.     if ($binlogs) {
  187.         if (PMA_DBI_num_rows($binlogs) > 0) {
  188.             PMA_printListItem($strBinaryLog, 'li_mysql_binlogs',
  189.                 './server_binlog.php?' . $common_url_query);
  190.         }
  191.         PMA_DBI_free_result($binlogs);
  192.     }
  193.     unset($binlogs);
  194.  
  195.     PMA_printListItem($strDatabases, 'li_mysql_databases',
  196.         './server_databases.php?' . $common_url_query);
  197.     PMA_printListItem($strExport, 'li_export',
  198.         './server_export.php?' . $common_url_query);
  199.     PMA_printListItem($strImport, 'li_import',
  200.         './server_import.php?' . $common_url_query);
  201.  
  202.     /**
  203.      * Change password
  204.      *
  205.      * @todo ? needs another message
  206.      */
  207.     if ($cfg['ShowChgPassword']) {
  208.         PMA_printListItem($strChangePassword, 'li_change_password',
  209.             './user_password.php?' . $common_url_query);
  210.     } // end if
  211.  
  212.     // Logout for advanced authentication
  213.     if ($cfg['Server']['auth_type'] != 'config') {
  214.         $http_logout = ($cfg['Server']['auth_type'] == 'http')
  215.                      ? '<a href="./Documentation.html#login_bug" target="documentation">'
  216.                         . ($cfg['ReplaceHelpImg'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_info.png" width="11" height="11" alt="Info" />' : '(*)') . '</a>'
  217.                      : '';
  218.         PMA_printListItem('<strong>' . $strLogout . '</strong> ' . $http_logout,
  219.             'li_log_out',
  220.             './index.php?' . $common_url_query . '&old_usr=' . urlencode($PHP_AUTH_USER), null, '_parent');
  221.     } // end if
  222.  
  223.     echo '</ul>';
  224. } // end of if ($server > 0)
  225. ?>
  226. </div>
  227. <div id="pmamaininformation">
  228. <?php
  229.  
  230. echo '<h1 xml:lang="en" dir="ltr">phpMyAdmin - ' . PMA_VERSION . '</h1>'
  231.     . "\n";
  232.  
  233. echo '<ul>' . "\n";
  234.  
  235. /**
  236.  * Displays the MySQL servers choice form
  237.  */
  238. if (!$cfg['LeftDisplayServers'] && (count($cfg['Servers']) > 1 || $server == 0 && count($cfg['Servers']) == 1)) {
  239.     echo '<li id="li_select_server">';
  240.     require_once './libraries/select_server.lib.php';
  241.     PMA_select_server(true, true);
  242.     echo '</li>';
  243. }
  244.  
  245. if ($server > 0) {
  246.     PMA_printListItem($strMysqlClientVersion . ': ' . PMA_DBI_get_client_info(),
  247.         'li_mysql_client_version');
  248.     PMA_printListItem($strUsedPhpExtensions . ': ' . $GLOBALS['cfg']['Server']['extension'],
  249.         'li_used_php_extension');
  250. }
  251.  
  252. // Displays language selection combo
  253. if (empty($cfg['Lang'])) {
  254.     echo '<li id="li_select_lang">';
  255.     require_once './libraries/display_select_lang.lib.php';
  256.     PMA_select_language();
  257.     echo '</li>';
  258. }
  259.  
  260.  
  261. if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding']
  262.   && $server != 0 && $allow_recoding && PMA_MYSQL_INT_VERSION < 40100) {
  263.     echo '<li id="li_select_charset">';
  264.     ?>
  265.     <form method="post" action="index.php" target="_parent">
  266.     <input type="hidden" name="server" value="<?php echo $server; ?>" />
  267.     <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  268.     <?php echo $strMySQLCharset;?>:
  269.     <select name="convcharset"  xml:lang="en" dir="ltr"
  270.         onchange="this.form.submit();">
  271.     <?php
  272.     foreach ($cfg['AvailableCharsets'] AS $id => $tmpcharset) {
  273.         if ($convcharset == $tmpcharset) {
  274.             $selected = ' selected="selected"';
  275.         } else {
  276.             $selected = '';
  277.         }
  278.         echo '        '
  279.            . '<option value="' . $tmpcharset . '"' . $selected . '>' . $tmpcharset . '</option>' . "\n";
  280.     }
  281.     ?>
  282.     </select>
  283.     <noscript><input type="submit" value="<?php echo $strGo;?>" /></noscript>
  284.     </form>
  285.     </li>
  286.     <?php
  287. }
  288.  
  289. // added by Michael Keck <mail_at_michaelkeck_dot_de>
  290. // ThemeManager if available
  291.  
  292. if ($GLOBALS['cfg']['ThemeManager']) {
  293.     echo '<li id="li_select_theme">';
  294.     echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
  295.     echo '</li>';
  296. }
  297. echo '<li id="li_select_fontsize">';
  298. echo PMA_Config::getFontsizeForm();
  299. echo '</li>';
  300. PMA_printListItem($strPmaDocumentation, 'li_pma_docs', 'Documentation.html', null, '_blank');
  301. PMA_printListItem($strPmaWiki, 'li_pma_docs', 'http://wiki.cihar.com', null, '_blank');
  302.  
  303. if ($cfg['ShowPhpInfo']) {
  304.     PMA_printListItem($strShowPHPInfo, 'li_phpinfo', './phpinfo.php?' . $common_url_query);
  305. }
  306.  
  307. // does not work if no target specified, don't know why
  308. PMA_printListItem($strHomepageOfficial, 'li_pma_homepage', 'http://www.phpMyAdmin.net/', null, '_blank');
  309. ?>
  310.     <li><bdo xml:lang="en" dir="ltr">
  311.         [<a href="changelog.php" target="_blank">ChangeLog</a>]
  312.         [<a href="http://phpmyadmin.svn.sourceforge.net/viewvc/phpmyadmin/"
  313.             target="_blank">Subversion</a>]
  314.         [<a href="http://sourceforge.net/mail/?group_id=23067"
  315.             target="_blank">Lists</a>]
  316.         </bdo>
  317.     </li>
  318.     </ul>
  319. </div>
  320. <?php
  321. /**
  322.  * BUG: MSIE needs two <br /> here, otherwise it will not extend the outer div to the
  323.  * full height of the inner divs
  324.  */
  325. ?>
  326. <br class="clearfloat" />
  327. <br class="clearfloat" />
  328. </div>
  329.  
  330. <?php
  331. if (! empty($GLOBALS['PMA_errors']) && is_array($GLOBALS['PMA_errors'])) {
  332.     foreach ($GLOBALS['PMA_errors'] as $error) {
  333.         echo '<div class="error">' . $error . '</div>' . "\n";
  334.     }
  335. }
  336.  
  337. /**
  338.  * Warning if using the default MySQL privileged account
  339.  * modified: 2004-05-05 mkkeck
  340.  */
  341. if ($server != 0
  342.  && $cfg['Server']['user'] == 'root'
  343.  && $cfg['Server']['password'] == '') {
  344.     echo '<div class="warning">' . $strInsecureMySQL . '</div>' . "\n";
  345. }
  346.  
  347. /**
  348.  * Warning for PHP 4.2.3
  349.  * modified: 2004-05-05 mkkeck
  350.  */
  351. if (PMA_PHP_INT_VERSION == 40203 && @extension_loaded('mbstring')) {
  352.     echo '<div class="warning">' . $strPHP40203 . '</div>' . "\n";
  353. }
  354.  
  355. /**
  356.  * Nijel: As we try to handle charsets by ourself, mbstring overloads just
  357.  * break it, see bug 1063821.
  358.  */
  359. if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
  360.     echo '<div class="warning">' . $strMbOverloadWarning . '</div>' . "\n";
  361. }
  362.  
  363. /**
  364.  * Nijel: mbstring is used for handling multibyte inside parser, so it is good
  365.  * to tell user something might be broken without it, see bug #1063149.
  366.  */
  367. if ($GLOBALS['using_mb_charset'] && !@extension_loaded('mbstring')) {
  368.     echo '<div class="warning">' . $strMbExtensionMissing . '</div>' . "\n";
  369. }
  370.  
  371. /**
  372.  * Warning for old PHP version
  373.  */
  374. if (PMA_PHP_INT_VERSION < 40200) {
  375.     echo '<div class="warning">' . sprintf($strUpgrade, 'PHP', '4.2.0') . '</div>' . "\n";
  376. }
  377.  
  378. /**
  379.  * Warning for old MySQL version
  380.  * modified: 2004-05-05 mkkeck
  381.  */
  382. // not yet defined before the server choice
  383. if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 32332) {
  384.     echo '<div class="warning">' . sprintf($strUpgrade, 'MySQL', '3.23.32') . '</div>' . "\n";
  385. }
  386.  
  387. /**
  388.  * Warning about different MySQL library and server version
  389.  * (a difference on the third digit does not count)
  390.  */
  391. if ($server > 0 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)) {
  392.     echo '<div class="notice">'
  393.      . PMA_sanitize(sprintf($strMysqlLibDiffersServerVersion,
  394.             PMA_DBI_get_client_info(),
  395.             substr(PMA_MYSQL_STR_VERSION, 0, strpos(PMA_MYSQL_STR_VERSION . '-', '-'))))
  396.      . '</div>' . "\n";
  397. }
  398.  
  399. /**
  400.  * Warning about wrong controluser settings
  401.  */
  402. $strControluserFailed = 'Connection for controluser as defined in your config.inc.php failed.';
  403. if (defined('PMA_DBI_CONNECT_FAILED_CONTROLUSER')) {
  404.     echo '<div class="warning">' . $strControluserFailed . '</div>' . "\n";
  405. }
  406.  
  407. if (defined('PMA_WARN_FOR_MCRYPT')) {
  408.     echo '<div class="warning">' . PMA_sanitize(sprintf($strCantLoad, 'mcrypt')) . '</div>' . "\n";
  409. }
  410.  
  411. /**
  412.  * prints list item for main page
  413.  *
  414.  * @param   string  $name   displayed text
  415.  * @param   string  $id     id, used for css styles
  416.  * @param   string  $url    make item as link with $url as target
  417.  * @param   string  $mysql_help_page  display a link to MySQL's manual
  418.  * @param   string  $target special target for $url
  419.  */
  420. function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null)
  421. {
  422.     echo '<li id="' . $id . '">';
  423.     if (null !== $url) {
  424.         echo '<a href="' . $url . '"';
  425.         if (null !== $target) {
  426.            echo ' target="' . $target . '"';
  427.         }
  428.         echo '>';
  429.     }
  430.  
  431.     echo $name;
  432.  
  433.     if (null !== $url) {
  434.         echo '</a>' . "\n";
  435.     }
  436.     if (null !== $mysql_help_page) {
  437.         echo PMA_showMySQLDocu('', $mysql_help_page);
  438.     }
  439.     echo '</li>';
  440. }
  441.  
  442. /**
  443.  * Displays the footer
  444.  */
  445. require_once './libraries/footer.inc.php';
  446. ?>
  447.